@extends('layouts.layout')

@section('content')

    <div class="header">
        @include('layouts.count')

        <h1 class="page-title">文章管理</h1>
        <ul class="breadcrumb">
            <li  class="active">文章列表 </li>
        </ul>

    </div>

    <div class="btn-toolbar list-toolbar">
        <div class="btn-group">
            <a class="btn btn-primary" href="{{url('article/create')}}"><i class="fa fa-plus"></i> New Article</a>
        </div>

        {{--<button class="btn btn-default">Import</button>--}}
        {{--<button class="btn btn-default">Export</button>--}}

        <form action="{{url('article')}}" method="get">
            {{csrf_field()}}
            <div class="btn-group">
                <select name="category" id="DropDownTimezone" class="form-control">

                    <option value="-1" @if($status=='-1') selected @endif>全部</option>
                    <option value="0" @if($status=='0') selected @endif>待审核</option>
                    <option value="1" @if($status=='1') selected @endif>通过</option>
                    <option value="2" @if($status=='2') selected @endif>未通过</option>
                </select>
                <input type="hidden" name="category" value="-1" id="category">
            </div>

            <div class="btn-group">
                <button class="btn btn-default"  type="submit">搜索</button>
            </div>
        </form>
    </div>




    <table class="table table-bordered table-striped">
        <thead>
        <tr>
            <th>序号</th>
            <th style="width: 20em;">标题</th>
            <th>类别</th>
            <th>状态</th>
            <th>用户名</th>
            <th>机构名称</th>
            <th>发布时间</th>
            <th style="width: 10em;">操作</th>
        </tr>
        </thead>
        <tbody>
        @foreach($results as $k=>$v)
            <tr>
                <td>{{$v->id}}</td>
                <td>{{$v->title}}</td>

                <th>
                    @if($v->category=='1')
                        资讯
                    @elseif($v->category=='2')
                        公告
                    @elseif($v->category=='3')
                        重要信息
                    @elseif($v->category=='4')
                        人才政策
                    @elseif($v->category=='5')
                        产业政策
                    @endif
                </th>
                <th>
                    @if($v->status=='0')
                        <span style="color:#428bca ">待审核</span>
                        @elseif($v->status=='1')
                        <span style="color: green">通过</span>
                        @elseif($v->status=='2')
                        <span style="color: #FF0000">不通过</span>
                        @endif
                </th>
                <th>{{$v->name}}</th>
                <td>{{$v->organize_name}}</td>
                <td>{{$v->created_at->format('Y-m-d')}}</td>
                <td>

                    <a title="详情"href="javascript:;" onclick="see_detail('{{url('article/'.$v['id'])}}')"  style="margin-right: 5px; "><i class="fa fa-home"></i></a>
                    <a title="编辑" href="{{url('article/'.$v['id'].'/edit ')}}" style="margin-right: 5px; "><i class="fa fa-pencil"></i></a>
                    <a title="删除" style="cursor:pointer" id="btn_delete" role="button" data-toggle="modal" onclick="ec_delete('{{url("article/".$v['id'])}}')"><i class="fa fa-trash-o"></i></a>
                </td>
            </tr>

        @endforeach
        {{--<tr>--}}
        {{--<td>1</td>--}}
        {{--<td>Mark</td>--}}
        {{--<td>Tompson</td>--}}
        {{--<td>the_mark7</td>--}}
        {{--<td>--}}
        {{--<a href="user.html"><i class="fa fa-pencil"></i></a>--}}
        {{--<a href="#myModal" role="button" data-toggle="modal"><i class="fa fa-trash-o"></i></a>--}}
        {{--</td>--}}
        {{--</tr>--}}
        </tbody>
    </table>
    {{--分页--}}
    {{$results->links()}}



    <script type="text/javascript">
        function ec_delete( url){

            layer.confirm('确定要删除？', {
                btn: ['确定','返回'] //按钮
            }, function(){
//            执行ajax提交函数
                $.ajax({
                    url:url,
                    type:"DELETE",
                    data:{'_token':'{{csrf_token()}}'},
                    async:true,
                    success:function(data){
                        layer.msg(data.msg,{icon: 6,},function(){
                            window.parent.location.reload();

                        })
                    },
                    error:function(data){
                        layer.msg('网络错误',{
                            icon: 5,
                        })
                    }
                })


            }, function(){
                layer.msg('感谢你的手下留情',{
                    icon: 6,
                });
            });
        }

        /**
         * seletor 赋值函数
         */

        $('#DropDownTimezone').change(function(){
            $('#category').val($(this).val());
        });

        function see_detail(to_url){
            layer.open({
                type: 2,
                title: '文章详情',
                shadeClose: true,
                shade: 0.8,
                area: ['800px', '600px'],
                content: to_url ,//iframe的url
                end:function(){
                    location.reload();
                }
            });
        }

    </script>

    </div>
    @stop